package com.itwn.portal.mapper;

import com.itwn.portal.entity.Remark;
import com.itwn.portal.vo.RemarkVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface RemarkMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Remark record);

    Remark selectByPrimaryKey(Integer id);

    List<Remark> selectAll();

    int updateByPrimaryKey(Remark record);

    /**
     * 查询评论(按时间降序,二层楼)
     * @param
     * @return
     */
    List<RemarkVo> selectAllRemark(@Param("pid")int pid, @Param("comicName") String comicName,
                             @Param("username")String username,@Param("rid")int rid);

    /**
     * 查询所有二级评论(时间降序,父id不为0)
     * @return
     */
    List<RemarkVo> selectSecond(@Param("rid") int rid);

    List<RemarkVo> selectFirstRemark(@Param("rid")int rid);

    /**
     * 添加评论后评论数
     * @param pid
     */
    @Update("update t_remark set remark_count = remark_count +1 where id = #{pid}")
    int updateIncrRemCount(@Param("pid")Integer pid);


    int insertRemark(Remark remark);

    @Update("update t_remark set like_count = like_count + 1 where id = #{mid}")
    void likeThat(@Param("mid")Integer mid);

    List<RemarkVo> selectHotFirstRemark(@Param("rid") int rid);
}